using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.VisualStudio.Shell;

namespace VSSDKAssist.Platform.Helpers
{
	internal class PackageTypeLocator
	{
		IServiceProvider serviceProvider;

		public PackageTypeLocator(IServiceProvider provider)
		{
			this.serviceProvider = provider;
		}

		public IList<Type> LocatePackage()
		{
			List<Type> packageTypes = new List<Type>();

			TypeDiscoveryHelper typeDiscoveryHelper = new TypeDiscoveryHelper(this.serviceProvider);
			ICollection types = typeDiscoveryHelper.GetTypes(typeof(Package));

			foreach(Type type in types)
			{
				if(type.FullName != typeof(Package).FullName)
				{
					packageTypes.Add(type);
				}
			}

			return packageTypes;
		}
	}
}
